<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ include file="houtai_mainhead.jsp" %>
	
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="statics/css/manage.css" type="text/css"></link>
<script  src="statics/js/usermanage.js"></script>
<style type="text/css">
#friendlink{
	display: none;
	padding:20px;
}
</style>
<script type="text/javascript">
$(function(){
$(".flink").on("click", ".red", function() {
	  var index = layer.open({
		type : 1,
		area : [ '350px', '250px' ],
		skin : 'layui-layer-rim',
		title : [ '修改', 'font-size:18px;' ],
		content : $("#friendlink")
	}); 
	var dataid=$(this).attr("data-id");
	//获取数据
	$.post("friendlink",{
		dataid:dataid
	},function(data){
	$("#input1").attr("value",data.name);
	$("#input2").attr("value",data.address);
	})
	$("#friendlink").on("click", "button", function() {
		
	var input1=$("#input1").val();
	var input2=$("#input2").val();
	//提交数据
	
	$.post("friendmodify",{
		pid:1,
		id:dataid,		
		name:input1,
		address:input2
	},function(){
		window.location.reload();
		//layer.close(index);
	alert("修改成功");
	})
	});
});

$("body").on("click", "#tianjia", function() {
	  index = layer.open({
		type : 1,
		area : [ '350px', '250px' ],
		skin : 'layui-layer-rim',
		title : [ '添加', 'font-size:18px;' ],
		content : $("#friendlink")
	}); 
	 $("#friendlink").on("click", "button", function() {
		 layer.close(index);
		 var input1=$("#input1").val();
		var input2=$("#input2").val();
	//提交数据
		$.post("friendmodify",{
			pid:11,
			name:input1,
			address:input2
		},function(data){
		window.location.reload();
		alert("添加成功")
		})
	 })
});

});
</script>
</head>
<body>
	<a class="blueadd"   id="delete" onclick="deletesome(6)">-删除</a>
		<a class="blueadd"  id="tianjia">+添加</a>
	<table>
		<thead>
					<tr>
						<th><input type="checkbox" onclick="checkAll(this)"></th>
						<th>名字</th>
						<th>地址</th>
						<th>操作</th>
					</tr>
				</thead>

				<tbody class="flink">
				
					<c:forEach items="${Friendlink}" var="fr">
					<tr>
							<td><input type="checkbox" onchange="check()" id="${fr.friendId }"></td>
							<td>${fr.name}</td>
							<td>${fr.address}</td>
							<td>
							<div class="caozuo">
								<a class="red" data-id="${fr.friendId}">修改</a>
							</div>
							</td>
					</tr>
				</c:forEach>
				</tbody>
			</table>
			
	<div id="friendlink">
				链接名称：<input name="name" id="input1">
				<br>
				链接：<input name="address" id="input2">
				<br>
		<button>确认</button>
	</div>	
</body>
</html>